package com.jml.XSS攻击;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class XssFilter  implements Filter {

	public void init(FilterConfig filterConfig) {
		System.out.println("初始化XssFilter...");
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		System.out.println("doFilter....");
		HttpServletRequest req = (HttpServletRequest) request;
		XssHttpServerRequest xssHttpServerRequest = new XssHttpServerRequest(req);
		HttpServletResponse res = (HttpServletResponse) response;
		//放行   传入的是自定义的request
		chain.doFilter(xssHttpServerRequest, res);
	}

	@Override
	public void destroy() {

	}

}